/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.boatskeeper.server.handler.boat;

import net.customware.gwt.dispatch.server.ActionHandler;
import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.ActionException;
import org.lucava.boatskeeper.server.MockBoatDao;
import org.lucava.boatskeeper.shared.rpc.boat.SaveBoat;
import org.lucava.boatskeeper.shared.rpc.boat.SaveBoatResult;

/**
 *
 * @author glenn
 */
public class SaveBoatHandler implements ActionHandler<SaveBoat, SaveBoatResult> {

    @Override
    public Class<SaveBoat> getActionType() {
        return SaveBoat.class;
    }

    @Override
    public SaveBoatResult execute(SaveBoat a, ExecutionContext ec) throws ActionException {
        
        MockBoatDao.save(a.getBoat());
        
        SaveBoatResult saveBoatResult = new SaveBoatResult(a.getBoat());

        return saveBoatResult;
    }

    @Override
    public void rollback(SaveBoat a, SaveBoatResult r, ExecutionContext ec) throws ActionException {
    }
}
